/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.cmict.data.form.api.service;

import cn.hutool.core.collection.CollUtil;
import com.cmict.data.framework.common.pojo.PageParam;
import com.cmict.data.framework.common.pojo.PageResult;
import com.cmict.data.framework.common.util.collection.CollectionUtils;
import com.cmict.data.form.api.entity.SysCategory;

import javax.validation.Valid;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 类别表
 *
 * @author pigx code generator
 * @date 2022-03-14 11:37:08
 */
public interface SysCategoryService {

    /** 逻辑删除 */
    Boolean deleteSysCategory(Long id);

    SysCategory getSysCategory(Long id);

    Long createSysCategory(@Valid SysCategory sysCategory);

    void updateSysCategory(@Valid SysCategory sysCategory);

    /**
     * 获得指定编号类别表
     *
     * @param ids 类别表编号数组
     * @return 类别表列表
     */
    List<SysCategory> getSimpleSysCategorys(Collection<Long> ids);

    /**
     * 获得指定编号的类别表 Map
     *
     * @param ids 类别表编号数组
     * @return 类别表 Map
     */
    default Map<Long, SysCategory> getSysCategoryMap(Collection<Long> ids) {
        if (CollUtil.isEmpty(ids)) {
            return Collections.emptyMap();
        }
        List<SysCategory> list = getSimpleSysCategorys(ids);
        return CollectionUtils.convertMap(list, SysCategory::getId);
    }

    /**
     * 获得表单分类分页列表
     *
     * @param
     * @return 分页列表
     */
    List<SysCategory> getSysCategoryPage();

    /**
     * 获得表单分类分页列表
     *
     * @param pageParam 分页条件
     * @return 分页列表
     */
    PageResult<SysCategory> getFormPage(PageParam pageParam);

    /**
     * 获取所有分类
     *
     * @return 列表
     */
    List<SysCategory> getCategoryAll();

}
